/*
 * @Author: wuqingchun
 * @Date: 2024-09-20 16:47:24
 * @Description: redis 实现分布式锁
 * @LastEditors: wuqingchun
 * @LastEditTime: 2024-09-20 17:32:39
 */
#ifndef __REDIS_DISTRIBUTED_LOCK_H__
#define __REDIS_DISTRIBUTED_LOCK_H__

#include <string>

#include "hiredis/hiredis.h"

class CRedisDistributedLock
{
public:
    int32_t Init(const char* pcServerHost, uint16_t usPort);

    bool Accquire();
    bool Release();

private:
    std::string   m_strLockKey;
    redisContext* m_pstRedisCtx = nullptr;
};

#endif //__REDIS_DISTRIBUTED_LOCK_H__